<?php

class Response
{
	/**
	 * @var Response
	 */
	static private $_initiator = null;

	/**
	 * avoid public constructor
	 */
	protected function __construct()
	{
	}

	/**
	 * get initiator object
	 */
	static public function initiator()
	{
		if (null == self::initiator())
		{
			self::$_initiator = new self;
		}
	}

	/**
	 * Response::redirect('admin/log',array(id=>1))
	 * @param string $path
	 * @param array|string $params optional = null
	 * @param string $basePath optional = null
	 * @return void
	 */
	static public function redirect($path, $params = null, $host = null)
	{
		self::setHeader('location', Agilet::getUrl($path, $params, $host));
		exit ;
	}

	/**
	 * set header param
	 * Response::setHeader('location','http://www.google.com.vn')
	 * 
	 * @param string $header_name
	 * @param string $header_value
	 * @return void
	 */
	static public function setHeader($header_name, $header_value)
	{
		header((string)$header_name . ':' . (string)$header_value);
	}

	/**
	 * set list of header params
	 * Response::setHeader(array('status code'))
	 * @param array $params
	 * @return void
	 */
	static public function setHeaders($params)
	{
		foreach ($params as $header_name => $header_value)
		{
			header((string)$header_name . ':' . (string)$header_value);
		}
		return $this;
	}

}
